package com.mxf.code.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class TestFactory {
	/**
	 * 	初始化时可以自动将TestInterface加入到map中，
	 *  key为实现TestInterface类@Component("test1")指定的值
	 *  value为实现TestInterface类
	 *  Map<"test1",TestImpl1>
	 */
	@Autowired
	private Map<String, TestInterface> map = new ConcurrentHashMap<String, TestInterface>();
	
	public TestInterface geTestInterface(String key) {
		System.out.println(key);
		return map.get(key);
	}
}
